package cn.iocoder.yudao.module.erp.dal.mysql.purpurchaseorderitem;

import java.util.*;

import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.module.erp.dal.dataobject.purpurchaseorderitem.PurPurchaseOrderItemDO;
import org.apache.ibatis.annotations.Mapper;
import cn.iocoder.yudao.module.erp.controller.admin.purpurchaseorderitem.vo.*;

/**
 * ERP 采购单项 Mapper
 *
 */
@Mapper
public interface PurPurchaseOrderItemMapper extends BaseMapperX<PurPurchaseOrderItemDO> {

    default PageResult<PurPurchaseOrderItemDO> selectPage(PurPurchaseOrderItemPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<PurPurchaseOrderItemDO>()
                .eqIfPresent(PurPurchaseOrderItemDO::getPurchaseOrderId, reqVO.getPurchaseOrderId())
                .eqIfPresent(PurPurchaseOrderItemDO::getProductId, reqVO.getProductId())
                .eqIfPresent(PurPurchaseOrderItemDO::getProductUnit, reqVO.getProductUnit())
                .eqIfPresent(PurPurchaseOrderItemDO::getProductStandards, reqVO.getProductStandards())
                .eqIfPresent(PurPurchaseOrderItemDO::getProductPrice, reqVO.getProductPrice())
                .eqIfPresent(PurPurchaseOrderItemDO::getCount, reqVO.getCount())
                .eqIfPresent(PurPurchaseOrderItemDO::getTotalPrice, reqVO.getTotalPrice())
                .eqIfPresent(PurPurchaseOrderItemDO::getRemark, reqVO.getRemark())
                .eqIfPresent(PurPurchaseOrderItemDO::getCreator, reqVO.getCreator())
                .betweenIfPresent(PurPurchaseOrderItemDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(PurPurchaseOrderItemDO::getId));
    }

    default List<PurPurchaseOrderItemDO> selectListByPurchaseOrderId(String purchaseOrderId) {
        return selectList(PurPurchaseOrderItemDO::getPurchaseOrderId, purchaseOrderId);
    }

    default int deleteByPurchaseOrderId(String purchaseOrderId) {
        return delete(PurPurchaseOrderItemDO::getPurchaseOrderId, purchaseOrderId);
    }
}